package apps.softtech.Model;

import android.content.ContentValues;
import android.database.Cursor;

public class UserInfo {

	public static final String TABLE_NAME = "UserInfo";

	private int userId;
	public static final String ID = "id";
	public static final String USERID = "st_UserId";

	private String userName;
	public static final String USERNAME = "st_UserName";

	private String password;
	public static final String PASSWORD = "st_Password";

	private String email;
	public static final String EMAIL = "st_Email";

	private String phoneNumber;
	public static final String PHONENUMBER = "st_PhoneNumber";

	private String address;
	public static final String ADDRESS = "st_Address";

	private String createdDate;
	public static final String CREATED_DATE = "st_CreatedDate";

	private int userPermissionId;
	public static final String USER_PERMISSION_ID = "st_UserPermissionId";

	private float rate;
	public static final String RATE = "st_Rate";

	private double longitude;
	public static final String LONGITUDE = "st_Longitude";

	private double latitude;
	public static final String LATITUDE = "st_Latitude";

	private String gcmId;
	public static final String GCMID = "st_GcmId";

	private int isActive;
	public static final String ISACTIVE = "isActive";

	public static final String AVATAR_PATH = "st_AvatarPath";
	private String avatarPath;
	public static final String ST_USER_ID="UserId";
	private int st_UserId;

	public UserInfo() {
		super();
	}

	public UserInfo(int userId, String userName, String password, String email,
			String phoneNumber, String address, String createdDate,
			int userPermissionId, float rate, double longitude,
			double latitude, String gcmId, int isActive) {
		super();
		this.userId = userId;
		this.userName = userName;
		this.password = password;
		this.email = email;
		this.phoneNumber = phoneNumber;
		this.address = address;
		this.createdDate = createdDate;
		this.userPermissionId = userPermissionId;
		this.rate = rate;
		this.longitude = longitude;
		this.latitude = latitude;
		this.gcmId = gcmId;
		this.isActive = isActive;
	}

	/**
	 * contructor not contain userId
	 * 
	 * @param userName
	 * @param password
	 * @param email
	 * @param phoneNumber
	 * @param address
	 * @param createdDate
	 * @param userPermissionId
	 * @param rate
	 * @param longitude
	 * @param latitude
	 * @param gcmId
	 * @param isActive
	 */
	public UserInfo(String userName, String password, String email,
			String phoneNumber, String address, String createdDate,
			int userPermissionId, float rate, double longitude,
			double latitude, String gcmId, int isActive) {
		super();
		this.userName = userName;
		this.password = password;
		this.email = email;
		this.phoneNumber = phoneNumber;
		this.address = address;
		this.createdDate = createdDate;
		this.userPermissionId = userPermissionId;
		this.rate = rate;
		this.longitude = longitude;
		this.latitude = latitude;
		this.gcmId = gcmId;
		this.isActive = isActive;
	}


	public UserInfo(String userName, String email, String phoneNumber,
			float rate, String avatarPath,int st_UserId) {
		super();
		this.userName = userName;
		this.email = email;
		this.phoneNumber = phoneNumber;
		this.rate = rate;
		this.avatarPath = avatarPath;
		this.st_UserId = st_UserId;
	}

	public String getAvatarPath() {
		return avatarPath;
	}

	public void setAvatarPath(String avatarPath) {
		this.avatarPath = avatarPath;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public int getUserPermissionId() {
		return userPermissionId;
	}

	public void setUserPermissionId(int userPermissionId) {
		this.userPermissionId = userPermissionId;
	}

	public float getRate() {
		return rate;
	}

	public void setRate(float rate) {
		this.rate = rate;
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	public String getGcmId() {
		return gcmId;
	}

	public void setGcmId(String gcmId) {
		this.gcmId = gcmId;
	}

	public int getIsActive() {
		return isActive;
	}

	public void setIsActive(int isActive) {
		this.isActive = isActive;
	}

	public int getSt_UserId() {
		return st_UserId;
	}

	public void setSt_UserId(int st_UserId) {
		this.st_UserId = st_UserId;
	}

	/**
	 * get value of UserInfo
	 * 
	 * @author MUI
	 * @return ContentValues
	 */
	public ContentValues getValueUserInfo() {
		ContentValues values = new ContentValues();

		values.put(USERNAME, this.getUserName());
		values.put(CREATED_DATE, this.getCreatedDate());
		values.put(EMAIL, this.getEmail());
		values.put(GCMID, this.getGcmId());
		values.put(ISACTIVE, this.getIsActive());
		values.put(LATITUDE, this.getLatitude());
		values.put(LONGITUDE, this.getLongitude());
		values.put(PASSWORD, this.getPassword());
		values.put(PHONENUMBER, this.getPhoneNumber());
		values.put(RATE, this.getRate());
		values.put(USER_PERMISSION_ID, this.getUserPermissionId());
		values.put(ADDRESS, this.getAddress());
		values.put(AVATAR_PATH, this.getAvatarPath());
		values.put(ST_USER_ID, this.getSt_UserId());
		return values;

	}

	public void setValueFromCursor(Cursor c) {

		if (c.getColumnIndex(USERID) >= 0) {
			setUserId(c.getInt(c.getColumnIndex(USERID)));
		}
		if (c.getColumnIndex(USERNAME) >= 0) {
			setUserName(c.getString(c.getColumnIndex(USERNAME)));
		}
		if (c.getColumnIndex(ADDRESS) >= 0) {
			setAddress(c.getString(c.getColumnIndex(ADDRESS)));
		}
		
		if (c.getColumnIndex(PASSWORD) >= 0) {
			setPassword(c.getString(c.getColumnIndex(PASSWORD)));
		}
		if (c.getColumnIndex(EMAIL) >= 0) {
			setPassword(c.getString(c.getColumnIndex(EMAIL)));
		}
		if (c.getColumnIndex(PHONENUMBER) >= 0) {
			setPhoneNumber(c.getString(c.getColumnIndex(PHONENUMBER)));
		}
		if (c.getColumnIndex(USER_PERMISSION_ID) >= 0) {
			setUserPermissionId(c.getInt(c
					.getColumnIndex(USER_PERMISSION_ID)));
		}
		if (c.getColumnIndex(CREATED_DATE) >= 0) {
			setCreatedDate(c.getString(c.getColumnIndex(CREATED_DATE)));
		}
		if (c.getColumnIndex(RATE) >= 0) {
			setRate(c.getFloat(c.getColumnIndex(RATE)));
		}
		if (c.getColumnIndex(LONGITUDE) >= 0) {
			setLongitude(c.getDouble(c.getColumnIndex(LONGITUDE)));
		}
		if (c.getColumnIndex(LATITUDE) >= 0) {
			setLatitude(c.getDouble(c.getColumnIndex(LATITUDE)));
		}
		if (c.getColumnIndex(GCMID) >= 0) {
			setGcmId(c.getString(c.getColumnIndex(GCMID)));
		}
		if (c.getColumnIndex(ISACTIVE) >= 0) {
			setIsActive(c.getInt(c.getColumnIndex(ISACTIVE)));
		}
		if (c.getColumnIndex(AVATAR_PATH) >= 0) {
			setAvatarPath(c.getString(c.getColumnIndex(AVATAR_PATH)));
		}
		if (c.getColumnIndex(ST_USER_ID) >= 0) {
			setSt_UserId(c.getInt(c.getColumnIndex(ST_USER_ID)));
		}

	}
}
